﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace App_Code.Helpers
{
    /// <summary>
    /// Summary description for MultiUploadExtractor
    /// </summary>
    public class MultiUploadExtractor
    {
        public static List<string> GetMovieUrls(string content)
        {
            //var movieUrls = new List<string>();
            //return movieUrls;

            throw new NotImplementedException("Method not implemeted");
        }

        public static VideoResult ExtractMovieUrl(string movieUrl)
        {
            var pageContent = Utils.GetPage(movieUrl, Encoding.UTF8);
            var video_link = Regex.Match(pageContent, "alt=\"Megaupload\".*?<a href=\"(.+?)\"", RegexOptions.Singleline).Groups[1].Value;
            var movieName = Regex.Match
                (pageContent,
                 "<div style=\"position:absolute; left:5px; top:35px; width:788px; text-align:center; font-size:15px; color:#000000;\">(.+?)<",
                 RegexOptions.Singleline).Groups[1].Value;
            return new VideoResult(video_link, movieName, true);
        }

        public static bool IsContainVideoLink(string content)
        {
            const string URL_REGEX = "www.multiupload.com";
            var match = Regex.Match(content, URL_REGEX, RegexOptions.IgnoreCase);
            return match.Success;
        }
    }
}